#!/bin/bash
# chkconfig: - 90 20
# description: Liferay

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

MIP="172.16.1.138"
USER="teleepoch"
PASSWD="1234"
MCMD="/usr/local/bin/mysql"
LIP=`ifconfig |grep "172.16"|awk '{print $2}'|cut -d ':'  -f 2`
QID=`$MCMD -u$USER -p$PASSWD -h$MIP -e "show processlist;"|grep lportal|grep $LIP|awk '{print $1}'`
echo $QID
if [ "$QID"!='' ] ; then
for i in $QID
do
$MCMD  -u$USER -p$PASSWD -h$MIP  -e "kill $i"
done
fi


PATH=/usr/local/jdk/bin:$PATH:./

export PATH
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=/usr/local/jdk/lib/tools.jar:/usr/local/jdk/jre/lib/rt.jar:.
export CATALINA_HOME=/usr/local/dongyou/tomcat

unset USERNAME

start()
        {
        cd $CATALINA_HOME/bin
        sh startup.sh
       }

stop()
        {
        cd $CATALINA_HOME/bin
        sh shutdown.sh
        }

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
restart)
        stop
        start
        ;;

*)
 echo "start | stop | restart"
esac
